from rest_framework.decorators import api_view
from rest_framework.response import Response
from student.models import StuSerializer
from student.models import StudentData

@api_view(["GET"])
def search_by_stuid(request):
    stuid = request.query_params.get("stuid",None)
    if not stuid:
        query_set = StudentData.objects.all()
    else:
        query_set = StudentData.objects.filter(stuid__contains=stuid)
    datas = StuSerializer(instance=query_set,many=True).data
    return Response(data=datas)